package com.cl;

import com.cl.dao.CommonDao;
import com.cl.entity.BaseAuthor;
import com.cl.entity.UUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import com.cl.dao.SearchDao;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.testng.annotations.Test;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by Administrator on 2015/6/26.
 */
@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/spring/root-context.xml"})
//@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public class SyncOutsideUser extends AbstractTestNGSpringContextTests {

    @Autowired
    private SearchDao<?> searchDao;

    @Autowired
    private CommonDao commonDao;

    @Test
    public void TestSyncOutSideUser() throws JsonProcessingException {
        List<BaseAuthor> authors = searchDao.getAllAuthors();
        if (authors != null && authors.size() > 0) {
            for(BaseAuthor author:authors) {
                UUser user = new UUser();
                user.setName(author.getName());
                user.setDuty(author.getTitle());
                user.setSex(author.getSex());
                user.setCorp(author.getCorp());
                user.setPhone(author.getTelephone());
                user.setGid(new BigDecimal(5));
                user.setIdentificationUnit("院外");
//                commonDao.saveDBOject(user);
            }
        }
    }

}
